/*
 * @Description: 工厂模式
 * @Author: rendc
 * @Date: 2022-10-10 11:13:09
 * @LastEditors: rendc
 * @LastEditTime: 2022-10-10 11:19:42
 */
function createPerson (name, age, gender) {
  var obj = new Object();
  obj.name = name;
  obj.age = age;
  obj.gender = gender;
  obj.sayName = function () {
    console.log('my name is' + this.name)
  };
  obj.sayGender = function () {
    console.log('my name is' + this.gender)
  };
  obj.sayAge = function () {
    console.log('my name is' + this.age)
  };
  return obj;
}
function createDog (name, age, gender) {
  var obj = new Object();
  obj.name = name;
  obj.age = age;
  obj.gender = gender;
  obj.sayName = function () {
    console.log('my name is' + this.name)
  };
  obj.sayGender = function () {
    console.log('my name is' + this.gender)
  };
  obj.sayAge = function () {
    console.log('my name is' + this.age)
  };
  return obj;
}
var obj1 = createPerson("tom", 12, 1);
var obj2 = createPerson("larry", 22, 2);
var obj3 = createPerson("larry", 22, 2);
var obj4 = createDog("狗子", 2, 2);
console.log(typeof obj1);
console.log(typeof obj2);
console.log(typeof obj4);